package org.jakim.entity;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="EDUCATION")
public class Education implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3346460847067662448L;
	
	@Id
	@GeneratedValue
	@Column(name="EDUCATION_ID")
	private Integer educationId;
	
	@Column(name="EDUCATION_START_DATE")
	private Date educationStartDate;
	
	@Column(name="EDUCATION_END_DATE")
	private Date educationEndDate;
	
	@Column(name="EDUCATION_QUALIFICATION_TITLE")
	private String educationQualificationTitle;
	
	@Column(name="EDUCATION_SKILLS")
	private String educationOccupationalSkills;
	
	@Column(name="EDUCATION_ORGANIZATION_NAME")
	private String educationOrganisationName;
	
	@Column(name="EDUCATION_LEVEL")
	private String educationClassificationLevel;
	
	@ManyToOne
	@JoinColumn(name="PERSONAL_INFO_ID")
	private PersonalInforamation personalInforamation;
	
	@Column(name="EDUCATION_ORGANIZATION_TYPE")
	private String educationOrganisationType;
	
	@Column(name="EDUCATION_ORGANIZATION_STREET")
	private String educationStreet;
	
	@Column(name="EDUCATION_ORGANIZATION_CITY")
	private String educationCity;
	
	@Column(name="EDUCATION_ORGANIZATION_COUNTRY")
	private String educationCountry;
	
	@Column(name="EDUCATION_ORGANIZATION_FIELD")
	private String educationOrganiztaionField;
	
	@Column(name="EDUCATION_ORGANIZATION_POSTCODE")
	private Integer educationPostalCode;

	public Education(){
		
	}
	
	public String getEducationOrganisationType() {
		return educationOrganisationType;
	}

	public void setEducationOrganisationType(String educationOrganisationType) {
		this.educationOrganisationType = educationOrganisationType;
	}

	public Date getEducationStartDate() {
		return educationStartDate;
	}

	public void setEducationStartDate(Date educationStartDate) {
		this.educationStartDate = educationStartDate;
	}

	public Date getEducationEndDate() {
		return educationEndDate;
	}

	public void setEducationEndDate(Date educationEndDate) {
		this.educationEndDate = educationEndDate;
	}

	public String getEducationQualificationTitle() {
		return educationQualificationTitle;
	}

	public void setEducationQualificationTitle(String educationQualificationTitle) {
		this.educationQualificationTitle = educationQualificationTitle;
	}

	public String getEducationOccupationalSkills() {
		return educationOccupationalSkills;
	}

	public void setEducationOccupationalSkills(String educationOccupationalSkills) {
		this.educationOccupationalSkills = educationOccupationalSkills;
	}

	public String getEducationOrganisationName() {
		return educationOrganisationName;
	}

	public void setEducationOrganisationName(String educationOrganisationName) {
		this.educationOrganisationName = educationOrganisationName;
	}

	public String getEducationClassificationLevel() {
		return educationClassificationLevel;
	}

	public void setEducationClassificationLevel(String educationClassificationLevel) {
		this.educationClassificationLevel = educationClassificationLevel;
	}

	public PersonalInforamation getPersonalInforamation() {
		return personalInforamation;
	}

	public void setPersonalInforamation(PersonalInforamation personalInforamation) {
		this.personalInforamation = personalInforamation;
	}

	public Integer getEducationId() {
		return educationId;
	}

	public String getEducationStreet() {
		return educationStreet;
	}

	public void setEducationStreet(String educationStreet) {
		this.educationStreet = educationStreet;
	}

	public String getEducationCity() {
		return educationCity;
	}

	public void setEducationCity(String educationCity) {
		this.educationCity = educationCity;
	}

	public String getEducationCountry() {
		return educationCountry;
	}

	public void setEducationCountry(String educationCountry) {
		this.educationCountry = educationCountry;
	}

	public String getEducationOrganiztaionField() {
		return educationOrganiztaionField;
	}

	public void setEducationOrganiztaionField(String educationOrganiztaionField) {
		this.educationOrganiztaionField = educationOrganiztaionField;
	}

	public Integer getEducationPostalCode() {
		return educationPostalCode;
	}

	public void setEducationPostalCode(Integer educationPostalCode) {
		this.educationPostalCode = educationPostalCode;
	}
	
	public String getHTMLDates(){
		String htmlDates;
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		
		String endDate = (this.educationEndDate != null) ? df.format(this.educationEndDate) : "Onwards";
		
		htmlDates = df.format(this.educationStartDate);
		htmlDates += " - " + endDate;
		
		return htmlDates;
	}
}
